<extend name="Base/ucmobile_base" />
<block name="body">
    <style>
        .header {
            text-align: center;
        }
        .header h1 {
            font-size: 200%;
            color: #333;
            margin-top: 30px;
        }
        .header p {
            font-size: 14px;
        }
    </style>
    <div class="header">
        <div class="am-g">
            <h1>{$appinfo.public_name}</h1>
        </div>
        <hr />
    </div>
    <div class="am-g">
        <div class="am-u-lg-6 am-u-md-8 am-u-sm-centered">
            <div class="am-cf">
                <div class="am-fl am-text-danger"><h2>找回密码</h2></div>
                <div class="am-fr"><h3>已有账号，<a href="{:U( 'Ucuser/Index/login',array('mp_id'=>$mp_id) )}">登录</a></h3></div>
            </div>
                <hr>
            <br>

            <form action="{:U( 'Ucuser/Index/forget',array('mp_id'=>$mp_id) )}" method="post" class="am-form am-form-horizontal">
                <div class="am-form-group">
                <label for="mobile" class="am-u-sm-3 am-form-label">手机:</label>
                    <div class="am-u-sm-9">
                <input type="text" name="mobile" id="mobile" value="">
                    </div>
                </div>
                <br>
                <div class="am-form-group">
                    <label for="password" class="am-u-sm-3 am-form-label">验证码:</label>
                    <div class="am-u-sm-9 am-form-inline">
                        <input type="number" id="verify" name="verify"/>
                        <button type="button" class="am-btn am-btn-primary btn_verify">点击获取</button>
                    </div>
                </div>
                <br>
                    <div class="am-form-group">
                    <label for="password" class="am-u-sm-3 am-form-label">新密码:</label>
                        <div class="am-u-sm-9">
                <input type="password" name="password" id="password" value="">
                    </div>
                    </div>
                <br>
                <div class="am-form-group">
                    <label for="password" class="am-u-sm-3 am-form-label">确认新密码:</label>
                    <div class="am-u-sm-9">
                        <input type="password" name="repassword" id="repassword" value="">
                    </div>
                </div>
                <br />
                <div class="am-cf">
                    <input type="submit" name="" value="确定" class="am-btn am-btn-primary am-btn-sm am-fl btn_submit">
                </div>
            </form>
            <hr>
            
        </div>
    </div>
</block><!--body end -->
<block name="script">
    <script type="text/javascript">
        var times= 60;
        var timer= null;

        $('.btn_verify').click(function(){
            if(timer){
                clearInterval(timer);
                timer= null;
            }
            timer= setInterval(function(){
                times--;
                if(times<=0){
                    clearInterval(timer);
                    $('.btn_verify').attr('value','点击获取').attr('disabled',false).css({'background':'#ffffff','color':'#f8b600'});
                    times= 60;

                }else{
                    $('.btn_verify').attr('value',times+'秒后重试').attr('disabled',true).css({'background':'#DDD','color':'#AAA'});

                }
            },1000);
        });

        $(".btn_verify").click(function () {
            var mobile = $("#phone").val();
            if($.trim(mobile)==""){
                alert('手机号不能为空');
                return false;
            }
            $.post("{:U('Ucuser/Index/sendVerify')}", {mobile:mobile}, function (res) {
                console.log(res);
                alert(res);
            })
        });

        $('.btn_submit').click(function(){
            var mobile=$('#phone').val();
            var verify=$('#verify').val();
            var password=$('#new_psd').val();
            var repassword=$('#renew_psd').val();
            if($.trim(mobile)==""){
                alert('手机号码不能为空');
                return false;
            }
            if($.trim(verify)==""){
                alert('请输入验证码');
                return false;
            }
            if($.trim(password)==""||$.trim(repassword)==""){
                alert('密码不能为空');
                return false;
            }
            if($("#new_psd").val()==$("#renew_psd").val())
            {

            }
            else{
                alert("2次输入的密码不一致,请重新输入");
            }
        });
    </script>
</block>

